home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / VerticalLine.java < prev    next >
Text File  |  1998-10-02  |  3KB  |  98 lines

  1. package symantec.itools.awt.shape;
  2.  
  3. import java.beans.PropertyVetoException;
  4. import java.awt.Dimension;
  5. import java.awt.Rectangle;
  6.  
  7. //  07/30/97    LAB    Updated version to 1.1.  Line can now be 1 pixel thick if it is
  8. //                    in BEVEL_LINE or BEVEL_NONE mode.
  9. //  08/13/97    LAB    Overrode setBevelStyle to reshape the component to have a thickness
  10. //                    of two pixels if the bevel style was rasied or lowered.  Addresses Mac
  11. //                    Bug #3571
  12. //    10/01/98    EB  Overrode getMinimumSize and getPreferredSize
  13.  
  14. /**
  15.  * This is a vertical line component.
  16.  * @version 1.2, October 1, 1998
  17.  * @author Symantec
  18.  */
  19. public class VerticalLine extends Rect
  20. {
  21.     /**
  22.      * Constructs a default VerticalLine.  The line width is 2.
  23.      */
  24.     public VerticalLine()
  25.     {
  26.         width = 2;
  27.     }
  28.  
  29.     /**
  30.      * Sets the border style of the shape.
  31.      * @see symantec.itools.awt.shape.Shape#getBevelStyle
  32.      *
  33.      * @exception PropertyVetoException
  34.      * if the specified property value is unacceptable
  35.      */
  36.     public void setBevelStyle(int s) throws PropertyVetoException
  37.     {
  38.         if(style != s)
  39.         {
  40.             super.setBevelStyle(s);
  41.             Rectangle r = getBounds();
  42.  
  43.             reshape(r.x, r.y, r.width == 1 ? 1 : 2, r.height);
  44.             validate();
  45.         }
  46.     }
  47.  
  48.     /**
  49.      * Moves and/or resizes this component.
  50.      * This is a standard Java AWT method which gets called to move and/or
  51.      * resize this component. Components that are in containers with layout
  52.      * managers should not call this method, but rely on the layout manager
  53.      * instead.
  54.      *
  55.      * @param x horizontal position in the parent's coordinate space
  56.      * @param y vertical position in the parent's coordinate space
  57.      * @param width the new width
  58.      * @param height the new height
  59.      */
  60.     public void reshape(int x, int y, int width, int height)
  61.     {
  62.         this.height = height;
  63.  
  64.         //Allow a 1 pixel width if the bevel style is line or none.
  65.         if (width == 1 && (style == BEVEL_LINE || style == BEVEL_NONE))
  66.             this.width = 1;
  67.         else
  68.             this.width = 2;
  69.  
  70.         super.reshape(x, y, this.width, height);
  71.     }
  72.  
  73.      /**
  74.      * Returns the minimum dimensions to properly display this component.
  75.      * This is a standard Java AWT method which gets called to determine
  76.      * the minimum size of this component.
  77.      * @see #getPreferredSize
  78.      */
  79.     public Dimension getMinimumSize()
  80.     {
  81.         return new Dimension(1, 2);
  82.     }
  83.  
  84.     /**
  85.      * Returns the recommended dimensions to properly display this component.
  86.      * This is a standard Java AWT method which gets called to determine
  87.      * the recommended size of this component.
  88.      *
  89.      * @see java.awt.Component#minimumSize
  90.      */
  91.     public Dimension getPreferredSize()
  92.     {
  93.         Dimension dim = getSize();
  94.         Dimension min = getMinimumSize();
  95.         return new Dimension(Math.max(dim.width, min.width), Math.max(dim.height, min.height));
  96.     }
  97. }
  98.